package demo4;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpdictServer extends UdpechoServer{

    private Map<String,String> dict=new HashMap<>();

    public UdpdictServer(int port) throws SocketException {
        super(port);
        dict.put("dog","小狗");
        dict.put("cat","小猫");
        dict.put("tiger","老虎");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该词典中没有这个词！");
    }

    public static void main(String[] args) throws IOException {
        UdpdictServer server=new UdpdictServer(60000);
        server.start();
    }
}
